#include <bits/stdc++.h>
using namespace std;
const int N = 5e6 + 10;

int n, k;
int a[N];

int quick(int l, int r, int k)
{
	if(l >= r) return a[l];
	int key = a[l + r >> 1];
	int i = l - 1, j = r + 1, t = l;
	while(t < j)
	{
		if(a[t] < key) swap(a[++ i], a[t ++]);
		else if(a[t] > key) swap(a[-- j], a[t]);
		else t ++;
	}
	int a = i - l + 1, b = j - i - 1, c = r - j + 1;
	if(k <= a) return quick(l, i, k);
	else if(k <= a + b) return key;
	else return quick(j, r, k - a - b);
}

int main()
{
	scanf("%d%d", &n, &k);
	k ++;
	for(int i = 1;i <= n;i ++) scanf("%d",&a[i]);
	printf("%d\n", quick(1, n, k));
	return 0;
}